<extend name="Layout/application"/>

<block name="content">
    <div class="row">
        <div class="col-md-12">

            <div class="row">
                <div class="col-md-8">
                    <div class="page-header">
                        <h1>系统首页</h1>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">栏目管理</div>
                        <a href="" target="_self" class="btn btn-info addcate">新增顶级栏目</a>
                        <button type="submit" class="btn btn-success sort_order">排序</button>

                        <div class="panel-body">

                            <table class="table table-striped">
                                <thead>
                                <tr>

                                    <th class="col-md-1">排序</th>
                                    <th class="col-md-6">名称</th>
                                    <th class="col-md-3">栏目文章</th>
                                    <th class="col-md-2"><span class="glyphicon glyphicon-search"></span></th>
                                </tr>
                                </thead>
                                <form method="post" action="" id="form">
                                <volist name="categories" id="c">


                                <tbody>
                                <tr>
                                    <input type="hidden" name="sort_id[]" value="{{$c.id}}">
                                    <td><input type="text" value="{{$c.sort_order}}"  name="sort_order[]"></td>
                                    <td class="col-md-6" >{{$c.name}}</td>
                                    <td class="col-md-3">{{$c.content}}</td>
                                    <td class="col-md-2">
                                        <a href="{{:U('add',array(id=>$c['id']))}}">
                                        <span class="glyphicon glyphicon-plus"></span>

                                    </a>
                                    <a href="{{:U('edit',array(id=>$c['id']))}}">
                                        <span class="glyphicon glyphicon-pencil"></span>
                                    </a>
                                     <a href="{{:U('destroy',array(id=>$c['id']))}}">
                                         <span class="glyphicon glyphicon-remove"></span>
                                     </a>
                                    </td>

                                </tr>
                                <volist name="c.children" id="a">


                                <tr>
                                    <input type="hidden" name="sort_id[]" value="{{$a.id}}">
                                    <td><input type="text" value="{{$a.sort_order}}"  name="sort_order[]"></td>
                                    <td class="col-md-6" >&nbsp;&nbsp;&nbsp;{{$a.name}}</td>
                                    <td class="col-md-3">{{$a.content}}</td>
                                    <td class="col-md-2">
                                        <a href="{{:U('add',array(id=>$a['id']))}}">
                                            <span class="glyphicon glyphicon-plus"></span>

                                        </a>
                                        <a href="{{:U('edit',array(id=>$a['id']))}}">
                                            <span class="glyphicon glyphicon-pencil"></span>
                                        </a>
                                        <a href="{{:U('destroy',array(id=>$a['id']))}}">
                                            <span class="glyphicon glyphicon-remove"></span>
                                        </a>

                                    </td>

                                </tr>
                                </volist>

                                </tbody>
                                </volist>
                                </form>
                            </table>

                        </div>
                    </div>
                </div>



            </div>
        </div>
    </div>
</block>
<block name="js">
    <script>
        $(function () {
            $(".sort_order").click(function () {
                $("#form").attr('action',"{{:U('sort_order')}}").submit();
            })

        })
    </script>
</block>